package com.example.asus.myapplication;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {
   Button mBtnTl;
    EditText mEtUsername;
    EditText mEtPassword;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        mBtnTl = findViewById(R.id.btn_tl);
        mEtUsername = findViewById(R.id.et_username);
        mEtPassword = findViewById(R.id.et_password);

        mBtnTl.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String username = mEtUsername.getText().toString();
                String password = mEtPassword.getText().toString();


                if (username.equals("admin") && password.equals("123")) {
                    // 跳转
                    Bundle bundle = new Bundle();
                    bundle.putString("usename",username);
                    bundle.putString("password",password);
                    Intent intent = new Intent(MainActivity.this,MyActitvity.class);
                    intent.putExtras(bundle);
                    startActivity(intent);
                } else {
                    Toast.makeText(MainActivity.this, "用户名错误或者密码错", Toast.LENGTH_SHORT).show();

                }
            }


        });



    }
}
